import Vue from 'vue'
import VueRouter from 'vue-router'
import Frame from "../src/components/frame.vue";
import {
	RouterTabRoutes
} from 'vue-router-tab';

const importPage = view => () =>
	import(`../page/${view}.vue`)

Vue.use(VueRouter);



const routes = [
	{
		path: '/',
		component: Frame,
		meta: {
			title: '主页' // 页签标题
		},
		children: [
			// 引入 RouterTab 内置路由以支持 iframe 页签
			...RouterTabRoutes,
			{
				path: '/', // 默认页和父级路由一致
				name: 'index',
				component: importPage('index'),
				meta: {
					title: '主页' // 页签标题
				}
			},
			{
				path: '/user',
				name: 'user',
				component: importPage('user/list'),
				meta: {
					title: '用户信息' // 页签标题
				}
			},
			{
				path: '/order/new',
				name: 'order_new',
				component: importPage('order/new'),
				meta: {
					title: '客户新增' // 页签标题
				}
			},
			{
				path: '/order/detail',
				name: 'order_detail',
				component: importPage('order/detail'),
				meta: {
					title: '客户信息详情' // 页签标题
				}
			},
			{
				path: '/order/userinfo',
				name: 'order_userinfo',
				component: importPage('order/userinfo'),
				meta: {
					title: '客户详情' // 页签标题
				}
			},
			{
				path: '/role',
				name: 'role',
				component: importPage('role/list'),
				meta: {
					title: '角色列表' // 页签标题
				}
			},
			{
				path: '/role/new',
				name: 'role_new',
				component: importPage('role/new'),
				meta: {
					title: '新增角色' // 页签标题
				}
			},
			{
				path: '/role/detail',
				name: 'role_detail',
				component: importPage('role/detail'),
				meta: {
					title: '角色详细' // 页签标题
				}
			},
			{
				path: '/permission',
				name: 'permission',
				component: importPage('permission/list'),
				meta: {
					title: '权限列表' // 页签标题
				}
			},
			{
				path: '/permission/new',
				name: 'permission_new',
				component: importPage('permission/new'),
				meta: {
					title: '新增权限' // 页签标题
				}
			},
			{
				path: '/permission/detail',
				name: 'permission_detail',
				component: importPage('permission/detail'),
				meta: {
					title: '权限详细' // 页签标题
				}
			},
			
			
			// 课程管理
			{
				path: '/car',
				name: 'car',
				component: importPage('car/list'),
				meta: {
					title: '车辆列表' // 页签标题
				}
			},
			{
				path: '/car/detail',
				name: 'car_detail',
				component: importPage('car/detail'),
				meta: {
					title: '车辆详细' // 页签标题
				}
			},
			{
				path: '/car/new',
				name: 'car_new',
				component: importPage('car/new'),
				meta: {
					title: '车辆新增' // 页签标题
				}
			},
            {
            	path: '/carSell',
            	name: 'carSell',
            	component: importPage('carSell/list'),
            	meta: {
            		title: '卖车列表' // 页签标题
            	}
            },
            {
            	path: '/carSell/detail',
            	name: 'carSell_detail',
            	component: importPage('carSell/detail'),
            	meta: {
            		title: '卖车详细' // 页签标题
            	}
            },
            {
            	path: '/carSell/new',
            	name: 'carSell_new',
            	component: importPage('carSell/new'),
            	meta: {
            		title: '卖车新增' // 页签标题
            	}
            },
            {
            	path: '/carBuy',
            	name: 'carBuy',
            	component: importPage('carBuy/list'),
            	meta: {
            		title: '买车列表' // 页签标题
            	}
            },
            {
            	path: '/carBuy/detail',
            	name: 'carBuy_detail',
            	component: importPage('carBuy/detail'),
            	meta: {
            		title: '买车详细' // 页签标题
            	}
            },
            {
            	path: '/carBuy/new',
            	name: 'carBuy_new',
            	component: importPage('carBuy/new'),
            	meta: {
            		title: '买车新增' // 页签标题
            	}
            },
            {
            	path: '/carRental',
            	name: 'carRental',
            	component: importPage('carRental/list'),
            	meta: {
            		title: '租车列表' // 页签标题
            	}
            },
            {
            	path: '/carRental/detail',
            	name: 'carRental_detail',
            	component: importPage('carRental/detail'),
            	meta: {
            		title: '租车详细' // 页签标题
            	}
            },
            {
            	path: '/carRental/new',
            	name: 'carRental_new',
            	component: importPage('carRental/new'),
            	meta: {
            		title: '租车新增' // 页签标题
            	}
            },
            {
            	path: '/carRent',
            	name: 'carRent',
            	component: importPage('carRent/list'),
            	meta: {
            		title: '求租列表' // 页签标题
            	}
            },
            {
            	path: '/carRent/detail',
            	name: 'carRent_detail',
            	component: importPage('carRent/detail'),
            	meta: {
            		title: '求租详细' // 页签标题
            	}
            },
            {
            	path: '/carRent/new',
            	name: 'carRent_new',
            	component: importPage('carRent/new'),
            	meta: {
            		title: '求租新增' // 页签标题
            	}
            },
            
			// 房子列表管理
			{
				path: '/house',
				name: 'house',
				component: importPage('house/list'),
				meta: {
					title: '房子列表' // 页签标题
				}
			},
			{
				path: '/house/detail',
				name: 'house_detail',
				component: importPage('house/detail'),
				meta: {
					title: '房子详细' // 页签标题
				}
			},
			{
				path: '/house/new',
				name: 'house_new',
				component: importPage('house/new'),
				meta: {
					title: '房子新增' // 页签标题
				}
			},
			{
				path: '/houseBuy',
				name: 'houseBuy',
				component: importPage('houseBuy/list'),
				meta: {
					title: '买房列表' // 页签标题
				}
			},
				
			{
				path: '/houseBuy/detail',
				name: 'houseBuy_detail',
				component: importPage('houseBuy/detail'),
				meta: {
					title: '买房详细' // 页签标题
				}
			},
			{
				path: '/houseBuy/new',
				name: 'houseBuy_new',
				component: importPage('houseBuy/new'),
				meta: {
					title: '买房新增' // 页签标题
				}
			},
			{
				path: '/houseLease',
				name: 'houseLease',
				component: importPage('houseLease/list'),
				meta: {
					title: '租房列表' // 页签标题
				}
			},
			{
				path: '/houseLease/detail',
				name: 'houseLease_detail',
				component: importPage('houseLease/detail'),
				meta: {
					title: '租房详细' // 页签标题
				}
			},
			{
				path: '/houseLease/new',
				name: 'houseLease_new',
				component: importPage('houseLease/new'),
				meta: {
					title: '租房新增' // 页签标题
				}
			},
			{
				path: '/houseRent',
				name: 'houseRent',
				component: importPage('houseRent/list'),
				meta: {
					title: '求租列表' // 页签标题
				}
			},
			{
				path: '/houseRent/detail',
				name: 'houseRent_detail',
				component: importPage('houseRent/detail'),
				meta: {
					title: '求租详细' // 页签标题
				}
			},
			{
				path: '/houseRent/new',
				name: 'houseRent_new',
				component: importPage('houseRent/new'),
				meta: {
					title: '求租新增' // 页签标题
				}
			},
			{
				path: '/houseSell',
				name: 'houseSell',
				component: importPage('houseSell/list'),
				meta: {
					title: '卖房列表' // 页签标题
				}
			},
			{
				path: '/houseSell/detail',
				name: 'houseSell_detail',
				component: importPage('houseSell/detail'),
				meta: {
					title: '卖房详细' // 页签标题
				}
			},
			{
				path: '/houseSell/new',
				name: 'houseSell_new',
				component: importPage('houseSell/new'),
				meta: {
					title: '卖房新增' // 页签标题
				}
			},
			
			
			// 客户页面
			{
				path: '/order',
				name: 'order',
				component: importPage('order/list'),
				meta: {
					title: '客户列表' // 页签标题
				}
			},
			
			{
				path: '/client/detail',
				name: 'client_detail',
				component: importPage('client/detail'),
				meta: {
					title: '客户详细' // 页签标题
				}
			},
			
			
			{
				path: '/page/:id',
				name: 'Page',
				component: importPage('Page'),
				meta: {
					key: 'path',
					title(route) {
						return `Page ${route.params.id}`
					}
				}
			},
			
			//订单类型价格
			{
				path: '/payCost',
				name: 'payCost',
				component: importPage('payCost/list'),
				meta: {
					title:'订单类型价格'// 页签标题
				}
			},
			{
				path: '/payCost/detail',
				name: 'payCost_detail',
				component: importPage('payCost/detail'),
				meta: {
					title: '订单类型价格详细' // 页签标题
				}
			}
			
		]
	}
];

const router = new VueRouter({
	routes
});
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
	return originalPush.call(this, location).catch(err => err)
}

export default router;
